﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BotDetector.Core.Search;
using BotDetector.Core.Model;

namespace BotDetector.Tests
{
    [TestClass]
    public class GoogleSearchUnitTests
    {
        private const string SEARCH_PHRASE = "ANA";
        private const string LANGUAGE = "Romanian";
        private const string COUNTRY = "Romania";
        private const int PAST_DAYS = 22;
        private const int PAST_WEEKS = 3;
        private const int PAST_MONTHS = 6;
        private const int PAST_YEARS = 2;

        private GoogleSearch googleSearch = new GoogleSearch();

        [TestMethod]
        public void Search_QuestionIsAna_True()
        {
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);

            Assert.IsTrue(resultItemList.Count > 0);
        }

        [TestMethod]
        public void SearchRestrictedToLanguage_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(LANGUAGE);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }

        [TestMethod]
        public void SearchRestrictedToCountry_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(country: COUNTRY);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }
        [TestMethod]
        public void SearchRestrictedToPastDays_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(pastDays: PAST_DAYS);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }
        [TestMethod]
        public void SearchRestrictedToPastWeeks_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(pastWeeks: PAST_WEEKS);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }
        [TestMethod]
        public void SearchRestrictedToPastMonths_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(pastMonths: PAST_MONTHS);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }
        [TestMethod]
        public void SearchRestrictedToPastYears_QuestionIsAna_True()
        {
            googleSearch.ConfigureSearch(pastYears: PAST_YEARS);
            ResultItemList resultItemList = googleSearch.Search(SEARCH_PHRASE);
            Assert.IsTrue(resultItemList.Count > 0);
        }

    }
}
